<?php include_once ('function/check_login_function.php'); onlyValid(); onlyPatient();?>
<!DOCTYPE html>
<html>
<head>
	<title>Doctors</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="">
</head>
<body>
	<div id="wrap">
		<header>
		</header>
		<div id="main">
			<div id="menu">
			</div>
			<div id="content">
				
					<?php 
					
					if (isset($_GET['hospital'])) {
						$doctor_list = null;
						$doctor_list = Hospital::getDoctorList($_GET['hospital']);
						$hospital_name = Hospital::findName($_GET['hospital']);
						echo '<h1>' . $hospital_name . '</h1>';
						if ($doctor_list !== null) {
							foreach ($doctor_list as $doctor) {
								echo '<div><ul>';
								echo '<li>' . $doctor['user_firstname'] . ' ' . $doctor['user_lastname'] . '</li>';
								echo '<li>' . $doctor['user_gender'] . '</li>';
								echo '<li>' . $doctor['user_email'] . '</li>';
								echo '<li>' . $doctor['user_contact'] . '</li>';
								echo '<li>' . $doctor['doctor_speciality'] . '</li>';
								echo '<li>' . $doctor['doctor_regno'] . '</li>';
								echo '<li><a href="request.php?doctor=' . $doctor['user_id'] . '">Select</a></li>';
								echo '</ul></div>';
							}
						}
					} else {
					?>
						<p>List of Doctors</p>
						<ol>
						<?php
							$doctor_list = $user->getDoctorList();
							if ($doctor_list !== null) {
								foreach ($doctor_list as $doctor) {
									echo '<form action="function/remove_request_function.php" method="POST">';
									echo '<li>';
									echo User::findName($doctor['doctor_id']);
									if (intval($doctor['request_pending']) === 0) {
										echo ' (Accepted) ';
									} else {
										echo ' (Pending) ';
									}
									$doctor_id = $doctor['doctor_id'];

									echo '<input type="hidden" id="doctor" name="doctor" value="' . $doctor_id . '"/>';
									echo '<input type="submit" name="remove" value="Remove Doctor" /> ';
									echo '</li>';
									echo' </form>';
								}
							} else {
								echo 'You have sent no doctors at this moment <br />';
								echo '<a href="hospitals.php">Click here</a> to get some <br />';
							}
						?>
						</ol>
					<?php }	?>				
			</div>
		</div>
		<footer>
			<div id="footer">
				
			</div>
		</footer>
	</div>
</body>